﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.TP
{
    class Class1
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {

                if (ppa.Period <= 1)
                {
                    da.Value = ppa.TotalFee;
                }
                else if (ppa.Period <= 2)
                {
                    da.Value = ppa.Amount * 0.7;
                }
                else
                {
                    da.Value = ppa.Amount;
                }
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period == ppa.PolicyActing.PeriodActings.Count() - 1)
            {
                da.Value = ppa.TotalFee;

            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                da.Value = ppa.TotalFee;
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("特种疾病"))
            {
                double v = ppa.GetDutyTotalValue("特种疾病");

                if (v <= double.Epsilon)
                {
                    da.Value = ppa.Amount * 0.1;
                }
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Age == 105)
            {
                da.Value = ppa.Amount;
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if ((ppa.Period + 1) % 2 == 0)
            {
                da.Value = ppa.Amount * 0.1;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {

                switch (ppa.Age)
                {
                    case 0:
                        da.Value = ppa.Amount * 0.2;
                        break;
                    case 1:
                        da.Value = ppa.Amount * 0.4;
                        break;
                    case 2:
                        da.Value = ppa.Amount * 0.6;
                        break;
                    case 3:
                        da.Value = ppa.Amount * 0.8;
                        break;
                    case 60:
                        da.Value = ppa.Amount * 2;
                        da.Description = "参考条款，注意时间限制!";
                        break;
                    default:
                        da.Value = ppa.Amount;
                        break;
                }
                ppa.IsCurrentFinish = true;
            }
        }
        //年度红利
        public void Calc200(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period > 0)
            {
                double f = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("分红率(预估)");

                ppa.Amount += ppa.PolicyActing.PeriodActings[ppa.Period - 1].Amount * f;
            }

        }
    }
}
